package com.goldenautumn.prefabricate.activity.mine.adapter

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.DataBindingHolder
import com.goldenautumn.prefabricate.R
import com.goldenautumn.prefabricate.business.entity.OrderMenuInfoVo
import com.goldenautumn.prefabricate.databinding.ItemOrderMenuBinding
import qncx.external.common.compat.isVisible

class OrderMenuAdapter  : BaseQuickAdapter<OrderMenuInfoVo, DataBindingHolder<ItemOrderMenuBinding>>() {

    override fun onBindViewHolder(holder: DataBindingHolder<ItemOrderMenuBinding>, position: Int, item: OrderMenuInfoVo?) {
        if(item == null) return
        var mBinding  = holder.binding
        item.icon?.let { mBinding.icon.setImageResource(it) }
        item.title?.let { mBinding.title.setText(it) }
        mBinding.count.isVisible(item.count != 0)
        mBinding.count.text = "${item.count}"
    }

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): DataBindingHolder<ItemOrderMenuBinding> {
        return DataBindingHolder(R.layout.item_order_menu,parent)
    }

}